<template>
  <div class="ele-body">
    <el-card shadow="never">
      <!-- 搜索表单 -->
      <task-search @search="reload" />
      <!-- 数据表格 -->
      <ele-pro-table
        ref="table"
        :columns="columns"
        :datasource="datasource"
        :selection.sync="selection"
      >
        <template v-slot:title_text_admission_special_img="{ row }">
          <el-avatar
            v-if="row.title_text_admission_special_img"
            :src="row.title_text_admission_special_img"
            shape="square"
            style="width: 110px; height: 50px"
          />
        </template>
        <template v-slot:deputy_title_text_admission_special_img="{ row }">
          <el-avatar
            v-if="row.deputy_title_text_admission_special_img"
            :src="row.deputy_title_text_admission_special_img"
            shape="square"
            style="width: 110px; height: 50px"
          />
        </template>

        <template v-slot:captions_text_admission_special_img="{ row }">
          <!-- <div>{{row.captions_text_admission_special_img}}</div> -->
          <img
            style="width: 110px; height: 50px"
            v-if="row.captions_text_admission_special_img"
            :src="row.captions_text_admission_special_img"
            alt=""
          />
          <!-- <el-avatar v-if="row.captions_text_admission_special_img" :src="row.deputy_title_text_admission_special_img" shape="square"  style="width: 110px; height: 50px" /> -->
        </template>
        <template v-slot:captions_flower_text_value="{ row }">
          <el-avatar
            v-if="row.captions_flower_text_value"
            :src="row.captions_flower_text_value"
            shape="square"
            style="width: 180px; height: 50px"
          />
        </template>
        <template v-slot:background_music="{ row }">
          <audio
            controls="controls"
            v-if="row.background_music"
            :src="row.background_music"
          />
        </template>
        <template v-slot:title_colour="{ row }">
          <div :style="{ color: row.title_colour }">背景颜色 </div>
        </template>

        <template v-slot:title_back_colour="{ row }">
          <div :style="{ color: row.title_back_colour }">背景颜色 </div>
        </template>

        <template v-slot:captions_colour="{ row }">
          <div :style="{ color: row.captions_colour }">背景颜色 </div>
        </template>

        <template v-slot:captions_back_colour="{ row }">
          <div :style="{ color: row.captions_back_colour }">背景颜色 </div>
        </template>

        <template v-slot:deputy_title_colour="{ row }">
          <div :style="{ color: row.deputy_title_colour }">背景颜色 </div>
        </template>

        <template v-slot:deputy_title_back_colour="{ row }">
          <div :style="{ color: row.deputy_title_back_colour }">背景颜色 </div>
        </template>

        <template v-slot:status="{ row }">
          <ele-dot
            v-if="row.status == 1"
            type="warning"
            effect="plain"
            text="等待提交媒资"
            :ripple="true"
          />
          <ele-dot
            v-if="row.status == 2"
            type="warning"
            effect="plain"
            text="合成中"
            :ripple="true"
            
          />
          <ele-dot
            v-if="row.status == 3"
            type="success"
            effect="plain"
            text="合成成功"
            :ripple="true"
          />
          <ele-dot
            v-if="row.status == 4"
            type="danger"
            effect="plain"
            text="等待合成"
            :ripple="true"
          />
          <ele-dot
            v-if="row.status == 5"
            type="danger"
            effect="plain"
            text="合成失败"
            :ripple="true"
          />
          <ele-dot
            v-if="row.status == 6"
            type="danger"
            effect="plain"
            text="部分合成"
            :ripple="true"
          />
        </template>

        <template v-slot:action="{ row }">
          <el-link
            type="success"
            :underline="false"
            icon="el-icon-more"
            @click="openMore(row)"
          >
            查看视频
          </el-link>
        </template>
      </ele-pro-table>
    </el-card>

    <ele-modal
      width="80%"
      :close-on-click-modal="false"
      custom-class="ele-dialog-form"
      title=" 视频数据"
      :visible.sync="showRepost"
    >
      <el-row>
        <el-col>
          <More :data="current" :videoId="id" @done="reload" />
        </el-col>
      </el-row>
    </ele-modal>
  </div>
</template>

<script>
import TaskSearch from './components/task-search';
import More from './components/more';
import { task } from '@/api/clip/index.js';

export default {
  name: 'Task',
  components: {
    TaskSearch,
    More
  },
  data() {
    return {
      // 表格列配置
      columns: [
        {
          columnKey: 'index',
          type: 'index',
          width: 45,
          align: 'center',
          showOverflowTooltip: true,
          fixed: 'left'
        },

        {
          prop: 'nickname',
          label: '剪辑用户',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'user'
        },

        {
          prop: 'title',
          label: '标题',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'title_font_value',
          label: '标题字体',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'title_time_desc',
          label: '标题展示时间',
          showOverflowTooltip: true,
          minWidth: 110
        },

        {
          prop: 'title_colour',
          label: '标题字体颜色',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'title_colour'
        },
        {
          prop: 'title_back_colour',
          label: '标题背景颜色',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'title_back_colour'
        },

        {
          prop: 'title_text_size_vlaue',
          label: '标题字体大小',
          showOverflowTooltip: true,
          minWidth: 110
        },

        {
          prop: 'deputy_title',
          label: '副标题',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'deputy_title_font_value',
          label: '副标题字体',
          showOverflowTooltip: true,
          minWidth: 110
        },

        {
          prop: 'deputy_title_time_desc',
          label: '副标题展示时间',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'deputy_text_size_vlaue',
          label: '副标题字体大小',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'deputy_title_colour',
          label: '副标题颜色',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'deputy_title_colour'
        },
        {
          prop: 'deputy_title_back_colour',
          label: '副标题背景颜色',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'deputy_title_back_colour'
        },

        {
          prop: 'background_music',
          label: '背景音乐',
          showOverflowTooltip: true,
          minWidth: 220,
          slot: 'background_music'
        },
        {
          prop: 'captions_font_value',
          label: '字幕字体',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'captions_text_size_value',
          label: '字幕字体大小',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'captions_colour',
          label: '字幕颜色',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'captions_colour'
        },

        {
          prop: 'captions_back_colour',
          label: '字幕背景颜色',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'captions_back_colour'
        },
        {
          prop: 'captions_text_admission_special_img',
          label: '字幕特效',
          showOverflowTooltip: true,
          minWidth: 110,
          slot: 'captions_text_admission_special_img'
        },

        {
          prop: 'captions_flower_text_value',
          label: '字幕花字',
          showOverflowTooltip: true,
          minWidth: 180,
          slot: 'captions_flower_text_value'
        },

        {
          prop: 'error_msg',
          label: '错误信息',
          showOverflowTooltip: true,
          minWidth: 180
        },

        {
          prop: 'status',
          label: '状态',
          align: 'center',
          width: 150,
          resizable: false,
          slot: 'status',
          showOverflowTooltip: true
        },
        {
          prop: 'create_time',
          label: '时间',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 100
        },
        {
          columnKey: 'action',
          label: '操作',
          width: 150,
          align: 'center',
          resizable: false,
          slot: 'action',
          hideInSetting: true,
          showOverflowTooltip: true
        }
      ],
      // 表格选中数据
      selection: [],
      // 当前编辑数据
      current: null,
      currentMore: null,
      // 是否显示编辑弹窗
      showEdit: false,
      // 是否显示审核弹窗
      showCheck: false,
      // 是否显示充值弹窗
      showRecharge: false,
      showRepost: false,

      //弹框名称
      id: 0,
      idMore: null,
      showMore: false
    };
  },
  methods: {
    beforeHandleCommand(index, row, command) {
      return {
        index: index,
        row: row,
        command: command
      };
    },

    /* 表格数据源 */
    datasource({ page, limit, where, order }) {
      return task({ ...where, ...order, page, limit });
    },
    /* 刷新表格 */
    reload(where) {
      this.$refs.table.reload({ page: 1, where: where });
    },

    openMore(row) {
      this.id = row.id;

      this.current = row;
      this.showRepost = true;
    },

    /* 删除 */
    remove(row) {
      const loading = this.$loading({ lock: true });
      remove(row.id)
        .then((msg) => {
          loading.close();
          this.$message.success(msg);
          this.reload();
        })
        .catch((e) => {
          loading.close();
          this.$message.error(e.message);
        });
    },
    /* 更新二维码 */

    /* 更改状态 */
    editStatus(row, statusValue) {
      const loading = this.$loading({ lock: true });
      updateGoodsStatus({ id: row.id, field: 'status', value: statusValue })
        .then((msg) => {
          loading.close();
          this.$message.success(msg);
          this.reload();
        })
        .catch((e) => {
          loading.close();
          this.$message.error(e.message);
        });
    }
  }
};
</script>
